package com.deeper.customview.ui.c4.demo.c04d01;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

public class ShaderView extends View {
    public ShaderView(Context context) {
        super(context);
    }


    public ShaderView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }


    public ShaderView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setTextSize(100);
        this.setLayerType(View.LAYER_TYPE_SOFTWARE, paint);
        paint.setShadowLayer(10, 1, 1, Color.RED);
        canvas.drawText("Android开发", 100, 100, paint);

        paint.setShadowLayer(10, 5, 5, Color.BLUE);
        canvas.drawText("Android绘图技术", 100, 220, paint);

        paint.setShadowLayer(0, 0, 0, Color.RED);
        canvas.drawText("Android", 100, 330, paint);
    }
}
